package com.ft.oa.web.dev;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ft.oa.domain.dev.DevProblem;
import com.ft.oa.domain.dev.DevProblemItem;
import com.ft.oa.domain.dev.DevTask;
import com.ft.oa.domain.dev.DevTaskItem;
import com.ft.oa.domain.development.DevAllocateStaff;
import com.ft.oa.domain.dto.ApiResult;
import com.ft.oa.service.dev.DevProblemItemService;
import com.ft.oa.service.dev.DevProblemService;
import com.ft.oa.service.dev.DevTaskItemService;
import com.ft.oa.service.dev.DevTaskService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 研发问题
 */

@RestController
@RequestMapping("/devProblem")
public class DevProblemController {

    @Resource
    private DevProblemService devProblemService;

    @Resource
    private DevProblemItemService devProblemItemService;

    @Resource
    private DevTaskService devTaskService;

    /**
     * 新增
     */
    @PostMapping("/add")
    public ApiResult add(@RequestBody DevProblem devProblem){
        ApiResult result = devProblemService.add(devProblem);
        return result;
    }

    /**
     * 新增问题进展
     * @param devProblemItem
     * @return
     */
    @PostMapping("/addItem")
    public ApiResult addDevProblemItem(@RequestBody DevProblemItem devProblemItem){
        ApiResult result = devProblemItemService.add(devProblemItem);
        return result;
    }

    /**
     * 分页
     */
    @PostMapping ("/page")
    public ApiResult page(@RequestBody DevProblem devProblem){
        Page<DevProblem> page = devProblemService.page(devProblem);
        return ApiResult.successWithData(page);
    }

    /**
     * 查询研发项目参与人（同项目任务）
     * @param devAllocateStaff
     * @return
     */
    @PostMapping("/queryDevAllocateStaff")
    public ApiResult queryDevAllocateStaff(@RequestBody DevAllocateStaff devAllocateStaff){
        ApiResult result = devTaskService.queryStaff(devAllocateStaff);
        return result;
    }

    /**
     * 查询项目任务详情
     * @param devProblem
     * @return
     */
    @PostMapping("/view")
    public ApiResult view(@RequestBody DevProblem devProblem){
        ApiResult result = devProblemService.view(devProblem);
        return result;
    }

    @PostMapping("/del")
    public ApiResult del(@RequestBody DevProblem devProblem){
        ApiResult result = devProblemService.del(devProblem);
        return result;
    }



}
